<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.prime.com.tr/ui"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:h="http://java.sun.com/jsf/html">

    <body>
        <ui:composition template="../templates/default3.xhtml">
            <ui:define name="content">
                <h:form id="viewMaterialRequirementPlans" binding="#{rawMaterialPurchasingManagerBean.loadViewMaterialRequirementPlans}">
                    <p:panel header="Material Requirement Plans" id="materialRequirementPlansPanel">
                        <p:messages />

                        <p:dataTable id="mrPlans" var="mrplans" value="#{rawMaterialPurchasingManagerBean.materialRequirementPlans}" 
                                     update="materialRequirementPlansPanel"  paginator="true" rows="10"  
                                     paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
                                     selection="#{rawMaterialPurchasingManagerBean.selectedMaterialRequirementPlans}"
                                     selectionMode="multiple"
                                     emptyMessage="No material requirement plans found with given criteria.">          
                            <p:column filterBy="#{mrplans.rawMaterial.name}" headerText="Raw Material Name" filterMatchMode="contains">  
                                <h:outputText value="#{mrplans.rawMaterial.name}" />  
                            </p:column> 
                            <p:column filterBy="#{mrplans.weight}" headerText="Required Amount (kg / litre)" filterMatchMode="contains">  
                                <h:outputText value="#{mrplans.weight}" />  
                            </p:column>
                            <p:column filterBy="#{mrplans.orderDate}" headerText="Date to Order" filterMatchMode="contains">  
                                <h:outputText value="#{mrplans.orderDate}" >
                                    <f:convertDateTime pattern="dd-MMM-yyyy" timeZone="#{defaultManagerBean.tz}"/>
                                </h:outputText>
                            </p:column>                        
                        </p:dataTable> 
                        <table class="table-submit">
                            <tr>
                                <td align="center">
                                    <p:commandButton id="btnPlaceOrder" value="Place an Order" 
                                                     title="Place order for selected raw material." ajax="true"
                                                     update="materialRequirementPlansPanel"
                                                     actionListener="#{rawMaterialPurchasingManagerBean.placeOrder}" />                              
                                </td>
                            </tr>
                        </table>
                    </p:panel>
                </h:form>
            </ui:define>
        </ui:composition>
    </body>
</html>
